public class Demo3 {
    volatile static boolean flag = true;
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            while(flag){

            }
            System.out.println("循环结束！");
        });
        t1.start();
        Thread.sleep(10);
        flag = false;
        t1.join();
    }
}
